import Vue from 'vue'
import App from './App.vue'
import router from './router.js'

// 导入 Element_ui
import './plugins/element.js'

// 导入全局初始化样式
import './assets/index.css'

//导入Nprogress包对应的js和css文件
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'


//导入axios
import axios from 'axios'

Vue.prototype.axios = axios
//拦截响应
axios.interceptors.response.use(res => {
  //隐藏请求加载进度条
  Nprogress.done()
  return res
})
//拦截请求响应
axios.interceptors.request.use(config => {
  //展示请求加载进度条
  Nprogress.start()
  return config;
})


Vue.filter('timeForm', function (originTime) {
  const t = new Date(originTime)
  const mm = (t.getMinutes() + '').padStart(2, '0') //不足两位以0拼接
  const ss = (t.getSeconds() + '').padStart(2, '0') //不足两位

  return `${mm}:${ss}`
})

Vue.filter('dateForm', function (originTime) {
  const dt = new Date(originTime)
  const yy = dt.getFullYear()
  const MM = (dt.getMonth() + 1 + '').padStart(2, '0') //不足两位以0拼接
  const dd = (dt.getDay() + '').padStart(2, '0') //不足两位以0拼接

  return `${yy}-${MM}-${dd}`
})

Vue.filter('dateFormat', function (originTime) {
  const dt = new Date(originTime)
  const yy = dt.getFullYear()
  const MM = (dt.getMonth() + 1 + '').padStart(2, '0') //不足两位以0拼接
  const dd = (dt.getDay() + '').padStart(2, '0') //不足两位以0拼接
  const hh = (dt.getHours() + '').padStart(2, '0') //不足两位以0拼接
  const mm = (dt.getMinutes() + '').padStart(2, '0') //不足两位以0拼接
  const ss = (dt.getSeconds() + '').padStart(2, '0') //不足两位以0拼接

  return `${yy}-${MM}-${dd} ${hh}:${mm}:${ss}`
})

Vue.filter('playCount', function (origin) {
  if (origin > 100000) {
    return parseInt(origin / 10000) + '万'
  } else {
    return origin
  }
})




Vue.config.productionTip = false

new Vue({
  render: h => h(App),
  // 挂载到Vue示例上
  router
}).$mount('#app')